//
//  LGBorderButton.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/3/13.
//  带边框的Button

#import "LGBorderButton.h"

@interface LGBorderButton()

/**   */
@property (nonatomic , copy)NSString *normalColor;
/**   */
@property (nonatomic , copy)NSString *selectColor;

@end

@implementation LGBorderButton

//添加边框
-(void)addBorder:(NSString *)borderColor lineWidth:(CGFloat)lineWidth cornerRidus:(CGFloat)radius{
    [super addBorder:borderColor lineWidth:lineWidth cornerRidus:radius];
    self.normalColor = borderColor;
    self.selectColor = borderColor;
}

//添加两种状态的边框
-(void)addBorderNormal:(NSString *)normalColor selectColor:(NSString *)selectColor lineWidth:(CGFloat)lineWidth cornerRidus:(CGFloat)radius{
    self.layer.borderColor = [UIColor colorWithString:normalColor].CGColor;
    self.layer.borderWidth = lineWidth;
    self.layer.cornerRadius = radius;
    self.normalColor = normalColor;
    self.selectColor = selectColor;
}



-(void)backColor:(NSString *)normalColor selectColor:(NSString *)selectColor{
    [self setBackgroundColor:[UIColor colorWithString:normalColor] forState:UIControlStateNormal];
    if(selectColor.length>0){
        [self setBackgroundColor:[UIColor colorWithString:selectColor] forState:UIControlStateSelected];
    }
}

-(void)borderColor:(NSString *)normalColor selectColor:(NSString *)selectColor{
    self.normalColor = normalColor;
    self.selectColor = selectColor;
}

-(void)setSelected:(BOOL)selected{
    [super setSelected:selected];
    if(selected == YES){
        self.layer.borderColor = [UIColor colorWithString:self.selectColor].CGColor;
    }else{
        self.layer.borderColor = [UIColor colorWithString:self.normalColor].CGColor;
    }
}



@end
